import 'package:flutter/material.dart';
import 'package:flutter_ability/custom_ui.dart';

class RadioWidget extends StatefulWidget {
  const RadioWidget({Key? key}) : super(key: key);

  @override
  State<RadioWidget> createState() => _RadioWidgetState();
}

class _RadioWidgetState extends State<RadioWidget> {
  int groupValue = 0;
  int groupValue2 = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: TextView.text("单选框"),
      ),
      backgroundColor: YJColors.BACKGROUND_COLOR,
      body: Container(
        margin: const EdgeInsets.symmetric(horizontal: 16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 20),
              child: TextView.text("垂直多选",
                  fontWeight: FontWeight.w600,
                  fontSize: 18,
                  color: YJColors.BLACK85),
            ),
            Container(
              color: Colors.white,
              padding: const EdgeInsets.only(
                  left: 16, right: 16, top: 10, bottom: 10),
              child: Column(
                children: [
                  YJRadio(
                    value: 0,
                    groupValue: groupValue2,
                    onChanged: (value) {
                      setState(() {
                        groupValue2 = value;
                      });
                    },
                  ),
                  const SizedBox(height: 16),
                  YJRadio(
                    value: 1,
                    groupValue: groupValue2,
                    onChanged: (value) {
                      setState(() {
                        groupValue2 = value;
                      });
                    },
                  ),
                ],
              ),
            ),
            const SizedBox(height: 16),
            Container(
              color: Colors.white,
              padding: const EdgeInsets.only(
                  left: 16, right: 16, top: 10, bottom: 10),
              child: buildRow(),
            )
          ],
        ),
      ),
    );
  }

  buildRow() {
    return Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          YJRadio(
            type: YJRadioType.custom,
            activeIcon: const Icon(Icons.check),
            radioColor: Colors.red,
            size: YJSize.LARGE,
            activeBgColor: YJColors.SUCCESS,
            inactiveBorderColor: YJColors.DARK,
            activeBorderColor: YJColors.SUCCESS,
            value: 12,
            groupValue: groupValue,
            onChanged: (value) {
              setState(() {
                groupValue = value;
              });
            },
          ),
          YJRadio(
            type: YJRadioType.custom,
            activeIcon: const Icon(Icons.sentiment_satisfied),
            size: YJSize.MEDIUM,
            value: 13,
            groupValue: groupValue,
            onChanged: (value) {
              setState(() {
                groupValue = value;
              });
            },
            inactiveIcon: const Icon(Icons.sentiment_dissatisfied),
            customBgColor: YJColors.WARNING,
            activeBgColor: YJColors.SUCCESS,
            activeBorderColor: YJColors.SUCCESS,
          ),
          YJRadio(
            type: YJRadioType.blunt,
            size: YJSize.SMALL,
            value: 14,
            groupValue: groupValue,
            onChanged: (value) {
              setState(() {
                groupValue = value;
              });
            },
            inactiveIcon: null,
            customBgColor: YJColors.SUCCESS,
            activeBorderColor: YJColors.SUCCESS,
          ),
          YJRadio(
            type: YJRadioType.blunt,
            size: 25,
            value: 15,
            groupValue: groupValue,
            onChanged: (value) {
              setState(() {
                groupValue = value;
              });
            },
            inactiveIcon: null,
            activeBorderColor: YJColors.SUCCESS,
            customBgColor: YJColors.SUCCESS,
          ),
        ]);
  }
}
